package com.atguigu.study.controller;

import com.atguigu.study.entity.User;
import com.atguigu.study.result.Result;
import com.atguigu.study.result.ResultCodeEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.atguigu.study.service.UserService;
/**
 * @Author early morning
 * @Create 2025/5/13 20:57
 * @Description:
 */
@RestController
public class UserController {
    @Autowired
    private UserService userService;

    @PostMapping("/user/add")
    public Result addUser(@RequestBody User user) {
        userService.addUser(user);
        return Result.ok();
    }

    @GetMapping("/user/{id}")
    public Result getUserById(@PathVariable Long id) {
        User userInfo = userService.getUserById(id);
        return Result.build(userInfo, ResultCodeEnum.SUCCESS);
    }
}
